package com.mybatis_multitable.mapper;

import com.mybatis_multitable.pojo.Orders;
import com.mybatis_multitable.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {
    
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "orderTime",column = "orderTime"),
            @Result(property = "total",column = "total"),
            @Result(property = "user",column = "uid",javaType = User.class,one = @One(select = "com.mybatis_multitable.mapper.UserMapper.getUserByUid"))
    })
    @Select("select * from orders")
    List<Orders> findOrders();
    
    @Select("select * from orders where uid = #{uid}")
    List<Orders> findByUid(Integer uid);
    
}
